package com.li.toolkit.utils;


import com.li.toolkit.constant.StringConst;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;

/**
 * @author LiDong
 * @version 1.0.0
 * @createTime 2/19/2022 10:12 AM
 */
public final class StrUtils {

    /**
     * 空串
     */
    public static final String EMPTY_STR = "";

    private StrUtils() {
    }

    /**
     * 字符串格式化为 单引号逗号分隔的字符串
     *
     * @param str 字符串
     * @return String
     */
    public static String strToSingleQuotes(String str) {
        if (StringUtils.isEmpty(str)) {
            throw new IllegalArgumentException("字符串不能为空！");
        }
        if (str.contains(StringConst.COMMA)) {
            return "'" + String.join("','", Arrays.asList(str.split(StringConst.COMMA))) + "'";
        }
        return "'" + str + "'";
    }


}
